{{HTML::script('js/plugins/jquery.min.js')}}
{{HTML::script('js/jquery-ui.min.js')}}
{{HTML::style('css/jquery-ui.css')}}
{{HTML::style('css/jquery-ui.min.css')}}
{{HTML::style('css/jquery-ui.structure.css')}}
{{HTML::style('css/jquery-ui.structure.min.css')}}
{{HTML::style('css/jquery-ui.theme.css')}}
{{HTML::style('css/jquery-ui.theme.min.css')}}
<div id="buttonBar">
	<div class="col-5 text-left pull-left">
		Font-size: <span class="font-size">20</span><br />
		<div id="slider"></div>
	</div>
	<div class="col-5 text-right pull-right">
		<button id="print">In hóa đơn</button>
		<button id="close">Đóng</button>
	</div>
</div>
<div id="printarea" class="row">
	<table>
		<thead>
			<tr>
				<th colspan="3">
					CÔNG TY TNHH SX-TM MP HÂN VY<br />
					Địa Chỉ: 35 Tam Hà, Phường Tam Phú, Quận Thủ Đức, TPHCM<br />
					Điện Thoại: (84-8) 3.986.1237 - Fax: (84-8) 3.729.6239<br />
					Điện Thoại Tư Vấn: 0973.479.839 - 0938.798.876<br />
				</th>
				<th class="text-right text-top" colspan="3" rowspan="2">
					<span class="customer">{{$customer->name}}</span><br />
					{{date("d-m-Y", strtotime($order->date))}}<br />
					Số HĐ: {{$order->order_number}}<br />
				</th>
			</tr>
			<tr>
				<th colspan="6" class="order_title">
					@if($customer->type == 'customer')
						Hóa đơn gởi hàng
					@else
						Hóa đơn mua hàng
					@endif	
				</th>
			</tr>
			<tr class="header">
				<th>{{trans('order.product_name')}}</th>
				<th style="width: 50px;">{{trans('order.net')}}</th>
				<th style="width: 80px;">{{trans('order.brand')}}</th>
				<th style="width: 80px;">{{trans('order.price')}}</th>
				<th style="width: 60px;">{{trans('order.quantity')}}</th>
				<th style="width: 80px;">{{trans('order.total')}}</th>
			</tr>
		</thead>
		<tbody>
			@foreach($items as $row)
			<tr id="order" data-id="{{$row->id}}">
				<td class="name">{{$row->name}}</td>
				<td class="net">{{$row->net}}</td>
				<td class="brand">{{$row->brand}}</td>
				<td class="price">{{MoneyFormat::format($row->price)}}</td>
				<td class="quantity">{{$row->quantity}}</td>
				<td class="total">{{MoneyFormat::format($row->price * $row->quantity)}}</td>
			</tr>
			@endforeach
		</tbody>
		<tfoot>
			<tr><td colspan="6"><br /></td></tr>
			@if($order->discount > 0)
			<tr>
				<td>
					Người viết hóa đơn
				</td>
				<td class="price" colspan="4">
					Giá chưa chiết khấu:
				</td>
				<td class="price">
					{{MoneyFormat::format($order->subtotal)}}
				</td>
			</tr>
			@endif
			<tr>
				<td>
					@if($order->discount == 0)
						Người viết hóa đơn
					@endif
				</td>
				<td class="price" colspan="4">
					Thành tiền:
				</td>
				<td class="price">
					{{MoneyFormat::format($order->total)}}
				</td>
			</tr>
			<tr>
				<td>
					
				</td>
				<td class="price" colspan="4">
					Nợ cũ:
				</td>
				<td class="price">
					{{MoneyFormat::format($dept)}}
				</td>
			</tr>
			<tr>
				<td>
					
				</td>
				<td class="price" colspan="4">
					Thanh toán:
				</td>
				<td class="price">
					{{MoneyFormat::format($totalpay)}}
				</td>
			</tr>
			<tr>
				<td>
					
				</td>
				<td class="price" colspan="4">
					Trả hàng:
				</td>
				<td class="price">
					{{MoneyFormat::format($refund)}}
				</td>
			</tr>
			<tr>
				<td>
					Thanh Khương
				</td>
				<td class="price" colspan="4">
					Còn lại:
				</td>
				<td class="price">
					{{MoneyFormat::format($order->total + $dept - $totalpay - $refund)}}
				</td>
			</tr>
		</tfoot>
	</table>
</div>
<script type="text/javascript">
$(document).ready(function() {
	$("button#print").click(function(event) {
		/* Act on the event */
		window.print();
	});

	$("#slider").slider({
		min: 10,
		max: 70,
		value: 20,
		step: 1,
		slide: function(event, ui){
			$("tbody td, tfoot td").css('font-size', ui.value);
			$("span.font-size").text(ui.value);
		}
	});

	$("button#close").click(function(event) {
		/* Act on the event */
		var url = "{{URL::to('admin/order/list/' . $customer->type)}}";
		window.location = url;
	});
});
</script>
<style type="text/css">
.col-5{
	width: 50%;
}

.pull-left{
	float: left;
}

.pull-right{
	float: right;
}

.text-left{
	text-align: left;
}

.text-right{
	text-align: right;
}

.text-top{
	vertical-align: top;
}

#buttonBar{
	position: fixed;
	width: 800px;
	height: 50px;
	background-color: #e9e9e9;
	margin: auto;
	padding-top: 5px;
	top: 0;
	left: 10%;
	right: 10%;
	opacity: 0.7;
}

#buttonBar #slider{
	width: 200px;
	font-size: 10px;
	float: left;
	margin-top: 10px;
}

#printarea{
	padding-top: 60px;
	width: 800px;
	margin: auto;
}

.customer{
	font-size: 20pt;
	font-weight: bold;
	text-transform: uppercase;
}

.order_title{
	text-transform: uppercase;
	font-size: 18pt;
	font-weight: bold;
	text-align: center;
	padding: 5px 0;
}

table{
	width: 800px;
	margin: auto;
	border-collapse: collapse;
}

table tbody tr td{
	font-size: 20px;
}

th{
	text-align: left;
	font-weight: normal;
}

tr.header th{
	border: 1px solid black;
	padding: 3px 5px;
	font-weight: bold;
	text-align: center;
}

tr td{
	border: 1px solid black;
	padding: 3px 5px;
}

td.name{
	text-transform: capitalize;
}

td.price, td.brand, td.quantity, td.total{
	font-weight: bold;
	text-transform: uppercase;
}

td.price, td.total{
	text-align: right;
}

td.net, td.brand, td.quantity{
	text-align: center;
}

tfoot tr td:first-child{
	text-align: center;
}

tfoot td{
	border: none;
}

tfoot td.price{
	text-align: right;
	font-weight: bold;
	text-transform: capitalize;
}

@media print{
	#buttonBar{
		display: none;
	}

	#printarea{
		padding-top: 0;
	}
}
</style>